import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'

import IndexView from "@/views/IndexView.vue";
import SysIndexView from "@/views/system/SysIndexView.vue";
import DictView from "@/views/system/DictView.vue";
import BomIndexView from "@/views/bom/BomIndexView.vue";
import LabelIndex from "@/views/label/LabelIndex.vue";
import OrderIndexView from "@/views/order/OrderIndexView.vue";
import CustomerIndexView from "@/views/customer/CustomerIndexView.vue";
import MaterialView from "@/views/material/MaterialView.vue";
import MaterialIndexView from "@/views/material/MaterialIndexView.vue";
import WelcomeView from "@/views/index/WelcomeView.vue";
import OutIndexView from "@/views/out/OutIndexView.vue";
import AboutView from "@/views/AboutView.vue";
import OutCreateView from "@/views/out/OutCreateView.vue";
import OutListView from "@/views/out/OutListView.vue";
import BomListView from "@/views/bom/BomListView.vue";
import BomCreateView from "@/views/bom/BomCreateView.vue";
import CustomerCreateView from "@/views/customer/CustomerCreateView.vue";
import CustomerListView from "@/views/customer/CustomerListView.vue";
import BackupRestoreView from "@/views/system/BackupRestoreView.vue";
import CreateBucketView from "@/views/system/bucket/CreateBucketView.vue";
import OrderListView from "@/views/order/OrderListView.vue";
import OrderCreateView from "@/views/order/OrderCreateView.vue";
import StoreIndexView from "@/views/store/StoreIndexView.vue";
import StoreListView from "@/views/store/StoreListView.vue";
import StoreCreateView from "@/views/store/StoreCreateView.vue";
import TemplateIndexView from "@/views/system/template/TemplateIndexView.vue"
import TemplateCreateView from "@/views/system/template/TemplateCreateView.vue"
import TemplateListView from "@/views/system/template/TemplateListView.vue"

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'IndexView',
        component: IndexView,
        children: [
            {
                path: '/',
                name: 'WelcomeView',
                component: WelcomeView
            },
            {
                path: '/system',
                name: 'System',
                component: SysIndexView,
                meta: {breadcrumb: [{path: '/', label: '首页'}]},
                children: [
                    {
                        path: '/system/dict',
                        name: 'DictView',
                        component: DictView,
                    },
                    {
                        path: '/system/template',
                        name: 'TemplateIndexView',
                        component: TemplateIndexView,
                        children: [
                            {
                                path: '',
                                name: 'TemplateListView',
                                component: TemplateListView,
                            },
                            {
                                path: '/system/template/create',
                                name: 'TemplateCreateView',
                                component: TemplateCreateView,
                            },
                            {
                                path: '/system/template/edit/:formId',
                                name: 'TemplateEditView',
                                component: TemplateCreateView,
                            }
                        ]
                    },
                    {
                        path: '/system/bucket/create/:bucket',
                        name: 'CreateBucketView',
                        component: CreateBucketView,
                    }
                ]
            },
            {
                path: '/bom',
                name: 'Bom',
                component: BomIndexView,
                children: [
                    {
                        path: '',
                        name: 'BomList',
                        component: BomListView,
                    },
                    {
                        path: '/bom/create',
                        name: 'BomCreateView',
                        component: BomCreateView,
                    },
                    {
                        path: '/bom/edit/:id',
                        name: 'BomEditView',
                        component: BomCreateView,
                    }]
            },
            {
                path: '/lbl',
                name: 'Label',
                component: LabelIndex
            },
            {
                path: '/out',
                name: 'StoreOut',
                component: OutIndexView,
                children: [
                    {
                        path: '',
                        name: 'StoreOutList',
                        component: OutListView,
                    },
                    {
                        path: '/out/create',
                        name: 'StoreOutCreate',
                        component: OutCreateView,
                    }]
            },
            {
                path: '/store',
                name: 'StoreIndex',
                component: StoreIndexView,
                children: [
                    {
                        path: '',
                        name: 'StoreList',
                        component: StoreListView,
                    },
                    {
                        path: '/store/create',
                        name: 'StoreCreate',
                        component: StoreCreateView,
                    }]
            },
            {
                path: '/order',
                name: 'OrderIndexView',
                component: OrderIndexView,
                children: [
                    {
                        path: '',
                        name: 'OrderListView',
                        component: OrderListView
                    },
                    {
                        path: '/order/create',
                        name: 'OrderCreateView',
                        component: OrderCreateView
                    },
                    {
                        path: '/order/create/:id',
                        name: 'OrderEditView',
                        component: OrderCreateView
                    },
                ]
            },
            {
                path: '/mat',
                name: 'MaterialIndexView',
                component: MaterialIndexView,
                meta: {breadcrumb: [{path: '/', label: '首页'}]},
                children: [
                    {
                        path: '/mat/material',
                        name: 'MaterialView',
                        component: MaterialView
                    },
                ]
            },
            {
                path: '/customer',
                name: 'CustomerIndexView',
                component: CustomerIndexView,
                children: [
                    {
                        path: '',
                        name: 'CustomerListView',
                        component: CustomerListView
                    },
                    {
                        path: '/customer/create',
                        name: 'CustomerCreateView',
                        component: CustomerCreateView
                    },
                    {
                        path: '/customer/create/:id',
                        name: 'CustomerEditView',
                        component: CustomerCreateView
                    },
                ]
            }
        ]
    },
    {name: 'About', path: '/about', component: AboutView}
]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})

export default router
